<template>
  <div class="hot">
    <div class="title-holder"  @click="toNewHotGoods">
      <img src="../../assets/images/bgtopic.png" alt="" />
      <div class="title-box">
        <p class="title">人气推荐·好物精选</p>
        <p class="btn">查看全部</p>
      </div>
    </div>
    <div class="list-holder">
      <ul class="list">
        <li
          class="item"
          v-for="item in $store.state.home.hotGoods"
          :key="item.id"
          @click=toGoods(item.id);
        >
          <img :src="item.list_pic_url" alt="" />
          <p class="title">{{ item.name }}</p>
          <p class="desc">{{ item.goods_brief }}</p>
          <p class="price">￥ {{ item.retail_price }}</p>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  methods: {
    toGoods(id) {
      this.$router.push({ path: "/pages/goods/goods", query: { id: id } });
    },
    toNewHotGoods(){
      this.$router.push({path:'/pages/newshot/goods',query:{type:'isHot'}});
    }
  },
};
</script>

<style lang="scss">
.hot {
  .title-holder {
    position: relative;
    margin-top: 8px;
    height: 130px;
    img {
      height: 100%;
    }
    .title-box {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      text-align: center;
      .title {
        color: #8c9bae;
        font-size: 16px;
      }
      .btn {
        margin: 0 auto;
        margin-top: 18px;
        height: 24px;
        width: 90px;
        line-height: 24px;
        color: #8c9bae;
        background: #f4e9cb;
      }
    }
  }

  .list-holder {
    margin-top: 8px;
    .list {
      overflow: auto;
      height: 240px;
      white-space: nowrap;
      .item {
        display: inline-block;
        width: 180px;
        height: 98%;
        background-color: #fff;
        border-right: 1px solid #eee;
        box-sizing: border-box;
        img {
          display: block;
          width: 140px;
          height: 140px;
          margin: 0 auto;
        }
        p {
          margin: 0 auto;
          width: 130px;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
          text-indent: 1em;
        }
        .title {
          font-size: 15px;
          font-weight: 700;
        }
        .desc {
          margin-top: 16px;
          color: #8a8a8a;
        }
        .price {
          margin-top: 16px;
          color: #9c3232;
        }
      }
    }
  }
}
</style>